from PyQt5.QtWidgets import QApplication, QMessageBox
from PyQt5 import uic
import pymysql
#global updete_key
updete_key=0
delete_key=0
add_key=0
class Login:
    def __init__(self):
        # 从文件中加载UI定义designer
        self.ui = uic.loadUi("login.ui")
        self.ui.pushButton.clicked.connect(self.register)
        self.ui.pushButton_2.clicked.connect(self.foget_password)
        self.ui.pushButton_3.clicked.connect(self.login)
    # 初始化登录页面属性
    def register(self):
        self.ui.close()
        register.ui.show()
    #方法用于链接注册界面
    def foget_password(self):
        self.ui.close()
        back_password.ui.show()
    #方法用于拉起重置密码
    def login(self):
        if self.ui.lineEdit.text() and self.ui.lineEdit_2.text():
            login_id = int(self.ui.lineEdit.text())
            login_password = self.ui.lineEdit_2.text()
            sql = "SELECT user_password FROM users WHERE user_id='%d'" % (login_id)
            try:
                cur.execute(sql)  # 执行mysql语句
                result = cur.fetchall()  # 获取mysql执行结果
                if result:
                    for i in result:  # 遍历执行结果
                        return_data = i[0]  # 获取密码
                    if login_password == return_data:  # 查找密码
                        self.ui.close()
                        menu.ui.show()
                    else:
                        QMessageBox.information(self.ui, '登录失败', '密码错误！！！', QMessageBox.Ok)
                else:
                    QMessageBox.information(self.ui, '登录失败', '不存在该账号！！！', QMessageBox.Ok)
                #return return_data  # 返回密码
            except Exception as err:
                print("sql语句执行错误", err)
                conn.rollback()  # 错误回滚
        else:
            QMessageBox.information(self.ui, '登录失败', '账号或密码不能为空！！！', QMessageBox.Ok)
    # 方法用于登录
class Register:
    def __init__(self):
        # 从文件中加载UI定义designer
        self.ui = uic.loadUi("register.ui")
        self.ui.pushButton.clicked.connect(self.register)
        self.ui.pushButton_2.clicked.connect(self.back_login)
        self.ui.pushButton_3.clicked.connect(self.exit)
    # 初始化注册窗口属性
    def register(self):
        # self.ui.textEdit.clear()
        user_name = self.ui.lineEdit.text()#从输入框获取用户名
        user_password = self.ui.lineEdit_2.text()#从输入框获取用户密码
        if user_name and user_password:
            data = (user_name, user_password)
            sql = "insert into users(user_name,user_password) values('%s','%s')" % (data)
            try:
                cur.execute(sql)  # 执行mysql语句
                conn.commit()  # 更新
                print("注册成功")
                print("以下是您的个人信息，请注意保管！！！")
                sql = "select * from users order by user_id DESC LIMIT 1"
                cur.execute(sql)  # 执行mysql语句
                result = cur.fetchall()
                #return result  # 获取结果
            except Exception as err:
                print("sql语句执行错误", err)
                conn.rollback()  # 错误回滚
            self.ui.textEdit.append(f'注册成功')
            self.ui.textEdit.append(f'以下是您的个人信息，请注意保管！！！')
            self.ui.textEdit.append(f'{result}')
        else:
            QMessageBox.information(self.ui, '错误', '用户名或密码不允许为空', QMessageBox.Ok)
    def back_login(self):
        self.ui.close()
        login.ui.show()
    #   拉起登录界面
    def exit(self):
        self.ui.close()
        # 退出系统
class Foget_password:
    def __init__(self):
        # 从文件中加载UI定义designer
        self.ui = uic.loadUi("back_password.ui")
        self.ui.pushButton.clicked.connect(self.foget_password)
        self.ui.pushButton_2.clicked.connect(self.back_login)
        self.ui.pushButton_3.clicked.connect(self.exit)
        # 初始化管理员认证
    def foget_password(self):
        self.ui.textEdit.clear()
        user_id = (self.ui.lineEdit.text())
        if user_id:
            user_id=int(user_id)
        user_name = self.ui.lineEdit_2.text()
        if user_id and user_name:
            data = (user_id, user_name)
            if back_smg(data):
                self.ui.textEdit.append(f'找回密码成功')
                self.ui.textEdit.append(f'以下是您的个人信息，请注意保管！！！')
                self.ui.textEdit.append(f'{back_smg(data)}')
            else:
                QMessageBox.information(self.ui, '错误', '账号和用户名不匹配', QMessageBox.Ok)
        else:
            QMessageBox.information(self.ui, '错误', '编号或姓名不允许为空', QMessageBox.Ok)
    def back_login(self):
        self.ui.close()
        login.ui.show()
    #     拉起登录界面
    def exit(self):
        self.ui.close()
        # 退出系统
class Menu():
    def __init__(self):
        self.ui = uic.loadUi("menu.ui")
        self.ui.pushButton.clicked.connect(self.select)
        self.ui.pushButton_2.clicked.connect(self.add)
        self.ui.pushButton_3.clicked.connect(self.update)
        self.ui.pushButton_4.clicked.connect(self.delete)
        self.ui.pushButton_5.clicked.connect(self.back_login)
        self.ui.pushButton_6.clicked.connect(self.exit)
    # 初始化菜单界面
    def select(self):
        self.ui.close()
        select.ui.show()
        # 拉起查询员工信息页面
    def add(self):
        self.ui.close()
        add.ui.show()
        # 拉起添加员工信息页面

    def update(self):
        self.ui.close()
        update.ui.show()
        # 更新员工信息页面的拉起

    def delete(self):
        self.ui.close()
        delete.ui.show()
        # 删除员工信息页面拉起

    def back_login(self):
        self.ui.close()
        login.ui.show()
    #     返回登录界面

    def exit(self):
        self.ui.close()
        # 退出系统
class Select():
    def __init__(self):
        self.ui = uic.loadUi("select.ui")
        self.ui.pushButton.clicked.connect(self.select_all)
        self.ui.pushButton_2.clicked.connect(self.back_menu)
    def select_all(self):
        self.ui.textEdit.clear()
        if self.ui.comboBox_2.currentIndex()==0:
            order_id="empno"
        elif self.ui.comboBox_2.currentIndex()==1:
            order_id = "ename"
        elif self.ui.comboBox_2.currentIndex()==2:
            order_id = "job"
        elif self.ui.comboBox_2.currentIndex()==3:
            order_id = "mgr"
        elif self.ui.comboBox_2.currentIndex()==4:
            order_id = "sal"
        elif self.ui.comboBox_2.currentIndex()==5:
            order_id = "comm"
        elif self.ui.comboBox_2.currentIndex()==6:
            order_id = "deptno"

        if self.ui.comboBox_3.currentIndex() == 0:
            order_type = "ASC"
        elif self.ui.comboBox_3.currentIndex() == 1:
            order_type = "DESC"

        if self.ui.comboBox.currentIndex()==0:
            sql = "select * from emp ORDER BY %s %s "%(str(order_id),str(order_type))  ## 书写mysql语句
            #sql = "select * from emp "
            try:
                cur.execute(sql)  ## 执行mysql语句
                result = cur.fetchall()  ##获取 mysql 执行结果
            except Exception as err:
                print("sql语句执行错误", err)
                conn.rollback()  # 错误回滚
            self.ui.textEdit.append(f'以下查找的是全部信息！！')
            for i in result:
                self.ui.textEdit.append(f'{i}')
        if self.ui.comboBox.currentIndex()==1:
            sql = "select * from emp where empno='%d' ORDER BY %s %s" % (int(self.ui.lineEdit.text()),order_id,order_type)
            try:
                cur.execute(sql)          # 执行mysql语句
                result = cur.fetchall()   # 获取mysql执行结果
                self.ui.textEdit.append(f'以下是按照员工编号查找到的员工信息！！')
                for i in result:
                    self.ui.textEdit.append(f'{i}')
            except Exception as err:
                print("sql语句执行错误", err)
                conn.rollback()  # 错误回滚

        if self.ui.comboBox.currentIndex()==2:
            sql = "select * from emp where ename='%s' ORDER BY %s %s" % (self.ui.lineEdit.text(),order_id,order_type)
            try:
                cur.execute(sql)          # 执行mysql语句
                result = cur.fetchall()   # 获取mysql执行结果
                self.ui.textEdit.append(f'以下是按照员工姓名查找到的员工信息！！')
                for i in result:
                    self.ui.textEdit.append(f'{i}')
            except Exception as err:
                print("sql语句执行错误", err)
                conn.rollback()  # 错误回滚

        if self.ui.comboBox.currentIndex()==3:
            sql = "select * from emp where job='%s' ORDER BY %s %s" % (self.ui.lineEdit.text(),order_id,order_type)
            try:
                cur.execute(sql)          # 执行mysql语句
                result = cur.fetchall()   # 获取mysql执行结果
                self.ui.textEdit.append(f'以下是按照员工职位查找到的员工信息！！')
                for i in result:
                    self.ui.textEdit.append(f'{i}')
            except Exception as err:
                print("sql语句执行错误", err)
                conn.rollback()  # 错误回滚

        if self.ui.comboBox.currentIndex()==4:
            sql = "select * from emp where mgr='%d' ORDER BY %s %s" % (int(self.ui.lineEdit.text()),order_id,order_type)
            try:
                cur.execute(sql)          # 执行mysql语句
                result = cur.fetchall()   # 获取mysql执行结果
                self.ui.textEdit.append(f'以下是按照员工直属上级编号查找到的员工信息！！')
                for i in result:
                    self.ui.textEdit.append(f'{i}')
            except Exception as err:
                print("sql语句执行错误", err)
                conn.rollback()  # 错误回滚

        if self.ui.comboBox.currentIndex()==7:
            sql = "select * from emp where deptno='%d' ORDER BY %s %s " % (int(self.ui.lineEdit.text()),order_id,order_type)
            try:
                cur.execute(sql)          # 执行mysql语句
                result = cur.fetchall()   # 获取mysql执行结果
                self.ui.textEdit.append(f'以下是按照员工部门编号查找到的员工信息！！')
                for i in result:
                    self.ui.textEdit.append(f'{i}')
            except Exception as err:
                print("sql语句执行错误", err)
                conn.rollback()  # 错误回滚

    def back_menu(self):
        self.ui.close()
        menu.ui.show()
class Add():
    def __init__(self):
        self.ui = uic.loadUi("add.ui")
        self.ui.pushButton.clicked.connect(self.add_information)
        self.ui.pushButton_2.clicked.connect(self.back_menu)
        self.ui.pushButton_3.clicked.connect(self.check)

    def check(self):
        if self.ui.lineEdit.text():
            global add_key
            add_key = 0
            sql = "select * from emp where empno ='%d'"%(int(self.ui.lineEdit.text()))  ## 书写mysql语句
            try:
                cur.execute(sql)  ## 执行mysql语句
                result = cur.fetchall()  ##获取 mysql 执行结果
                if result:
                    QMessageBox.information(self.ui, '提示', '不可以使用该员工编号', QMessageBox.Ok)
                    self.ui.textEdit.append(f'不可以使用该员工编号')
                else:
                    add_key=1
                    QMessageBox.information(self.ui, '提示', '可以使用该员工编号', QMessageBox.Ok)
                    self.ui.textEdit.append(f'可以使用该员工编号')
                #return result
            except Exception as err:
                print("sql语句执行错误", err)
                conn.rollback()  # 错误回滚
        else:
            QMessageBox.information(self.ui, '警告', '请先输入员工编号', QMessageBox.Ok)
    def add_information(self):
        if add_key:
            if self.ui.lineEdit.text():
                sid = int(self.ui.lineEdit.text())
            else:
                sid = ""
            sname = self.ui.lineEdit_2.text()
            job = self.ui.lineEdit_3.text()
            if self.ui.lineEdit_4.text():
                mgr = int(self.ui.lineEdit_4.text())
            else:
                mgr = ""
            if self.ui.lineEdit_5.text():
                sal = float(self.ui.lineEdit_5.text())
            else:
                sal = ""
            if self.ui.lineEdit_6.text():
                comm = float(self.ui.lineEdit_6.text())
            else:
                comm = ""
            if self.ui.lineEdit_7.text():
                deptno = int(self.ui.lineEdit_7.text())
            else:
                deptno = ""
            data = (sid, sname, job, mgr, sal, comm, deptno)
            if sid and sname and job and mgr and sal and comm and deptno:
                sql = "insert into emp values ('%d','%s','%s','%d','%f','%f','%d')" % (data)
                try:
                    cur.execute(sql)
                    conn.commit()
                    # print("插入成功成功！")
                    QMessageBox.information(self.ui, '成功', '数据添加成功', QMessageBox.Ok)
                except Exception as err:
                    print("sql语句执行错误", err)
                    QMessageBox.information(self.ui, '错误', '数据添加失败', QMessageBox.Ok)
                    conn.rollback()  # 错误回滚
            else:
                # print("无数据")
                QMessageBox.information(self.ui, '错误', '数据没有添加完整', QMessageBox.Ok)
        else:
            QMessageBox.information(self.ui, '警告', '请先检查该员工编号', QMessageBox.Ok)

    def back_menu(self):
        self.ui.close()
        menu.ui.show()
class Update():
    def __init__(self):
        self.ui = uic.loadUi("update.ui")
        self.ui.pushButton.clicked.connect(self.update_information)
        self.ui.pushButton_2.clicked.connect(self.back_menu)
        self.ui.pushButton_3.clicked.connect(self.select)
    def select(self):
        if self.ui.lineEdit.text():
            self.ui.textEdit_2.clear()
            select_id = int(self.ui.lineEdit.text())
            sql = "select * from emp where empno='%d'" % (select_id)
            try:
                cur.execute(sql)  # 执行mysql语句
                result = cur.fetchall()  # 获取mysql执行结果
                if result:
                    global updete_key
                    updete_key=1
                    self.ui.textEdit_2.append(f'以下是需要修改的员工信息！！')
                    for i in result:
                        self.ui.textEdit_2.append(f'{i}')
                else:
                    QMessageBox.information(self.ui, '失败', '不存在该员工编号，请检查！！！', QMessageBox.Ok)
            except Exception as err:
                print("sql语句执行错误", err)
                conn.rollback()  # 错误回滚
        else:
            QMessageBox.information(self.ui, '警告', '先输入员工编号', QMessageBox.Ok)

    def update_information(self):
        if updete_key == 1:
            up_id = int(self.ui.lineEdit.text())
            new_data = self.ui.lineEdit_2.text()
            if self.ui.comboBox.currentIndex() == 0:
                up_information = "ename"
            elif self.ui.comboBox.currentIndex() == 1:
                up_information = "job"
            elif self.ui.comboBox.currentIndex() == 2:
                up_information = "mgr "
            elif self.ui.comboBox.currentIndex() == 3:
                up_information = "sal"
            elif self.ui.comboBox.currentIndex() == 4:
                up_information = "comm"
            elif self.ui.comboBox.currentIndex() == 5:
                up_information = "deptno"
            data = (up_information, new_data, up_id)
            sql = "update emp set %s = '%s' where empno='%d' " % (data)
            try:
                cur.execute(sql)
                conn.commit()
                sql = "select * from emp where empno ='%d' " % (up_id)  ## 书写mysql语句
                try:
                    cur.execute(sql)  ## 执行mysql语句
                    result = cur.fetchall()  ##获取 mysql 执行结果
                    if result:
                        QMessageBox.information(self.ui, '成功', '修改成功', QMessageBox.Ok)
                        self.ui.textEdit.clear()
                        self.ui.textEdit.append(f'以下是更新后的信息！！')
                        for i in result:
                            self.ui.textEdit.append(f'{i}')
                    else:
                        QMessageBox.information(self.ui, '失败', '不存在该员工编号，请检查', QMessageBox.Ok)
                except Exception as err:
                    print("sql语句执行错误", err)
                    conn.rollback()  # 错误回滚

            except Exception as err:
                QMessageBox.information(self.ui, '失败', '修改失败', QMessageBox.Ok)
                conn.rollback()  # 错误回滚
        else: QMessageBox.information(self.ui, '警告', '请先检查该员工编号的信息', QMessageBox.Ok)

    def back_menu(self):
        self.ui.close()
        menu.ui.show()
class Delete():
    def __init__(self):
        self.ui = uic.loadUi("delete.ui")
        self.ui.pushButton.clicked.connect(self.select_all)
        self.ui.pushButton_2.clicked.connect(self.delete)
        self.ui.pushButton_3.clicked.connect(self.back_menu)

    def select_all(self):
        global delete_key
        delete_key =0
        self.ui.textEdit.clear()
        if self.ui.comboBox.currentIndex()==0:
            #global  delete_key
            delete_key=1
            result = select_smg()
            self.ui.textEdit.append(f'以下查找的是全部信息！！')
            for i in result:
                self.ui.textEdit.append(f'{i}')

        else:
            if self.ui.lineEdit.text():
                if self.ui.comboBox.currentIndex() == 1:
                    sql = "select * from emp where empno='%d' " % (int(self.ui.lineEdit.text()))
                    try:
                        cur.execute(sql)  # 执行mysql语句
                        result = cur.fetchall()  # 获取mysql执行结果
                        if result:
                            delete_key = 1
                            self.ui.textEdit.append(f'以下是按照员工编号查找到的员工信息！！')
                            for i in result:
                                self.ui.textEdit.append(f'{i}')
                        else:
                            self.ui.textEdit.append(f'没有查找到对应的员工信息！！')
                    except Exception as err:
                        print("sql语句执行错误", err)
                        conn.rollback()  # 错误回滚
                if self.ui.comboBox.currentIndex() == 2:
                    sql = "select * from emp where ename='%s' " % (self.ui.lineEdit.text())
                    try:
                        cur.execute(sql)  # 执行mysql语句
                        result = cur.fetchall()  # 获取mysql执行结果
                        if result:
                            delete_key = 1
                            self.ui.textEdit.append(f'以下是按照员工姓名查找到的员工信息！！')
                            for i in result:
                                self.ui.textEdit.append(f'{i}')
                        else:
                            self.ui.textEdit.append(f'没有查找到对应的员工信息！！')
                    except Exception as err:
                        print("sql语句执行错误", err)
                        conn.rollback()  # 错误回滚
                if self.ui.comboBox.currentIndex() == 3:
                    sql = "select * from emp where job='%s' " % (self.ui.lineEdit.text())
                    try:
                        cur.execute(sql)  # 执行mysql语句
                        result = cur.fetchall()  # 获取mysql执行结果
                        if result:
                            delete_key = 1
                            self.ui.textEdit.append(f'以下是按照员工职位查找到的员工信息！！')
                            for i in result:
                                self.ui.textEdit.append(f'{i}')
                        else:
                            self.ui.textEdit.append(f'没有查找到对应的员工信息！！')
                    except Exception as err:
                        print("sql语句执行错误", err)
                        conn.rollback()  # 错误回滚
                if self.ui.comboBox.currentIndex() == 4:
                    sql = "select * from emp where mgr='%d' " % (int(self.ui.lineEdit.text()))
                    try:
                        cur.execute(sql)  # 执行mysql语句
                        result = cur.fetchall()  # 获取mysql执行结果
                        if result:
                            delete_key = 1
                            self.ui.textEdit.append(f'以下是按照员工直属上级编号查找到的员工信息！！')
                            for i in result:
                                self.ui.textEdit.append(f'{i}')
                        else:
                            self.ui.textEdit.append(f'没有查找到对应的员工信息！！')
                    except Exception as err:
                        print("sql语句执行错误", err)
                        conn.rollback()  # 错误回滚
                if self.ui.comboBox.currentIndex() == 7:
                    sql = "select * from emp where deptno='%d' " % (int(self.ui.lineEdit.text()))
                    try:
                        cur.execute(sql)  # 执行mysql语句
                        result = cur.fetchall()  # 获取mysql执行结果
                        if result:
                            delete_key = 1
                            self.ui.textEdit.append(f'以下是按照员工部门编号查找到的员工信息！！')
                            for i in result:
                                self.ui.textEdit.append(f'{i}')
                        else:
                            self.ui.textEdit.append(f'没有查找到对应的员工信息！！')
                    except Exception as err:
                        print("sql语句执行错误", err)
                        conn.rollback()  # 错误回滚
            else:
                QMessageBox.information(self.ui, '警告', '查找的内容不能为空', QMessageBox.Ok)

    def delete(self):
        if delete_key==1:
            if self.ui.comboBox.currentIndex() == 0:
                sql = "delete from emp  "
                try:
                    cur.execute(sql)
                    conn.commit()
                    QMessageBox.information(self.ui, '成功', '删除成功', QMessageBox.Ok)
                    # print("删除成功！")
                except Exception as err:
                    # print("sql语句执行错误", err)
                    QMessageBox.information(self.ui, '失败', '删除失败', QMessageBox.Ok)
                    conn.rollback()  # 错误回滚

            if self.ui.comboBox.currentIndex() == 1:
                sql = "delete from emp  where empno='%d' " % (int(self.ui.lineEdit.text()))
                try:
                    cur.execute(sql)
                    conn.commit()
                    QMessageBox.information(self.ui, '成功', '删除成功', QMessageBox.Ok)
                    # print("删除成功！")
                except Exception as err:
                    # print("sql语句执行错误", err)
                    QMessageBox.information(self.ui, '失败', '删除失败', QMessageBox.Ok)
                    conn.rollback()  # 错误回滚

            if self.ui.comboBox.currentIndex() == 2:
                sql = "delete from emp  where ename='%s' " % (self.ui.lineEdit.text())
                try:
                    cur.execute(sql)
                    conn.commit()
                    QMessageBox.information(self.ui, '成功', '删除成功', QMessageBox.Ok)
                    # print("删除成功！")
                except Exception as err:
                    # print("sql语句执行错误", err)
                    QMessageBox.information(self.ui, '失败', '删除失败', QMessageBox.Ok)
                    conn.rollback()  # 错误回滚

            if self.ui.comboBox.currentIndex() == 3:
                sql = "delete from emp  where job='%s' " % (self.ui.lineEdit.text())
                try:
                    cur.execute(sql)
                    conn.commit()
                    QMessageBox.information(self.ui, '成功', '删除成功', QMessageBox.Ok)
                    # print("删除成功！")
                except Exception as err:
                    # print("sql语句执行错误", err)
                    QMessageBox.information(self.ui, '失败', '删除失败', QMessageBox.Ok)
                    conn.rollback()  # 错误回滚

            if self.ui.comboBox.currentIndex() == 4:
                sql = "delete from emp  where mgr='%d' " % (self.ui.lineEdit.text())
                try:
                    cur.execute(sql)
                    conn.commit()
                    QMessageBox.information(self.ui, '成功', '删除成功', QMessageBox.Ok)
                    # print("删除成功！")
                except Exception as err:
                    # print("sql语句执行错误", err)
                    QMessageBox.information(self.ui, '失败', '删除失败', QMessageBox.Ok)
                    conn.rollback()  # 错误回滚

            if self.ui.comboBox.currentIndex() == 5:
                sql = "delete from emp  where deptno='%d' " % (self.ui.lineEdit.text())
                try:
                    cur.execute(sql)
                    conn.commit()
                    QMessageBox.information(self.ui, '成功', '删除成功', QMessageBox.Ok)
                    # print("删除成功！")
                except Exception as err:
                    # print("sql语句执行错误", err)
                    QMessageBox.information(self.ui, '失败', '删除失败', QMessageBox.Ok)
                    conn.rollback()  # 错误回滚

        else:
            QMessageBox.information(self.ui, '警告', '请先检查输入内容', QMessageBox.Ok)
        """
        sql = "delete from emp  where empno='%d' " % (data)
        try:
            cur.execute(sql)
            conn.commit()
            print("删除成功！")
        except Exception as err:
            print("sql语句执行错误", err)
            conn.rollback()  # 错误回滚
        """
    def back_menu(self):
        self.ui.close()
        menu.ui.show()
def back_smg(data):
    sql ="SELECT * FROM users WHERE user_id='%d' AND user_name='%s'  "%(data)
    try:
        cur.execute(sql)         #执行mysql语句
        result = cur.fetchall()
        return  result     #获取结果
    except Exception as err:
        print("sql语句执行错误", err)
        conn.rollback()  # 错误回滚
def select_smg():
    sql = "select * from emp"  ## 书写mysql语句
    try:
        cur.execute(sql)## 执行mysql语句
        result = cur.fetchall() ##获取 mysql 执行结果
        return result
    except Exception as err:
        print("sql语句执行错误", err)
        conn.rollback()  # 错误回滚

if __name__=="__main__":
    try:
        conn = pymysql.connect(host="localhost",
                               user="root",
                               passwd="123456",
                               database="ems")
        print("数据库连接成功！")
    except Exception as err:
        print("数据库连接失败" + str(err))
    app = QApplication([])
    cur = conn.cursor()

    login = Login()
    register = Register()
    back_password=Foget_password()
    menu =Menu()
    select=Select()
    add=Add()
    update=Update()
    delete=Delete()

    login.ui.show()
    app.exec_()


